package com.tianze.library.utils;

import android.content.Context;

import com.tianze.library.view.SimpleDialog;
import com.tianze.library.view.UpdateDialog;


/**
 * Created by kingtami.
 */
public class DialogUtils {

    private DialogUtils() {
        throw new UnsupportedOperationException("cannot be instantiated");
    }

    public static SimpleDialog getWaitDialog(Context context) {
        SimpleDialog simpleDialog = new SimpleDialog(context, SimpleDialog.PROGRESS_TYPE);
        return simpleDialog;
    }

    public static SimpleDialog getWarnDialog(Context context, String title) {
        SimpleDialog simpleDialog = new SimpleDialog(context, SimpleDialog.WARNING_TYPE)//
                                                                                        .setMessageText(
                                                                                                title)
                                                                                        .setConfirmText(
                                                                                                "知道了");
        return simpleDialog;
    }

    public static SimpleDialog getWarnDialog(Context context, String title, SimpleDialog.OnSimpleClickListener listener) {
        SimpleDialog simpleDialog = new SimpleDialog(context, SimpleDialog.WARNING_TYPE)//
                                                                                        .setMessageText(
                                                                                                title)
                                                                                        .setConfirmText(
                                                                                                "知道了")
                                                                                        .setConfirmClickListener(
                                                                                                listener);
        return simpleDialog;
    }

    public static SimpleDialog getConfirmDialog(Context context, String message, SimpleDialog.OnSimpleClickListener listener) {
        SimpleDialog sweetAlertDialog = //
                new SimpleDialog(context, SimpleDialog.NORMAL_TYPE)//
                                                                   .setMessageText(message)//
                                                                   .setConfirmClickListener(
                                                                           listener);
        return sweetAlertDialog;
    }

    public static SimpleDialog getCustomConfirmDialog(Context context, String message, String confirm, String cancel, SimpleDialog.OnSimpleClickListener confirmListener, SimpleDialog.OnSimpleClickListener cancelListener) {
        SimpleDialog sweetAlertDialog = //
                new SimpleDialog(context, SimpleDialog.NORMAL_TYPE)//
                                                                   .setMessageText(message)//
                                                                   .setCancelText(cancel)
                                                                   .setConfirmText(confirm)//
                                                                   .setCancelClickListener(
                                                                           cancelListener)//
                                                                   .setConfirmClickListener(
                                                                           confirmListener);
        sweetAlertDialog.setCanceledOnTouchOutside(null != cancelListener);
        return sweetAlertDialog;
    }

    public static UpdateDialog getUpdateDialog(Context context, String message, UpdateDialog.OnSimpleClickListener confirmListener, UpdateDialog.OnSimpleClickListener cancelListener) {
        UpdateDialog _updateDialog = new UpdateDialog(context).setChangeLog(message)
                                                              .addConfirmClickListener(
                                                                      confirmListener)
                                                              .addCancelClickListener(
                                                                      cancelListener);
        return _updateDialog;
    }

}
